package com.jinke.uang.common;

import com.jinke.uang.AppApplication;
import com.jinke.uang.R;
import com.jinke.uang.bean.IdentityData;

import java.util.Arrays;
import java.util.List;

public class RealNameAuthData {
    private static RealNameAuthData instance = new RealNameAuthData();
    private static IdentityData.IdentityBean identityBean = new IdentityData.IdentityBean();


    private RealNameAuthData() {

    }

    public static RealNameAuthData getInstance() {
        if (instance == null) {
            instance = new RealNameAuthData();
        }
        return instance;
    }

    public void putAllData(IdentityData.IdentityBean bean) {
        identityBean = bean;
    }

    public IdentityData.IdentityBean getAllData() {
        return identityBean;
    }

    public void putData(String key, String value) {
        List<String> arr = Arrays.asList(AppApplication.getContext().getResources().getStringArray(R.array.identity));

        if (key.equals(arr.get(0))) {
            identityBean.setRealName(value);
        } else if (key.equals(arr.get(1))) {
            identityBean.setIdentityCardNum(value);
        }  else if (key.equals(arr.get(2))) {
            identityBean.setBirthday(value);
        }
    }


    public String getData(String key) {
        List<String> arr = Arrays.asList(AppApplication.getContext().getResources().getStringArray(R.array.identity));
        String result = "";
        if (key.equals(arr.get(0))) {
            result = identityBean.getRealName();
        } else if (key.equals(arr.get(1))) {
            result = identityBean.getIdentityCardNum();
        }  else if (key.equals(arr.get(2))) {
            result = identityBean.getBirthday();
        }
        return result;
    }
}
